package com.hl.springcloud.pack.web;

import com.hl.springcloud.pack.service.IPackService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope
@RestController
public class PackController {

    @Autowired
    private CounterService counterService;

    private final Logger logger = Logger.getLogger(getClass());
    @Value("${from}")
    private String from;

    @Autowired
    private IPackService packService;

    @RequestMapping(value = "/add" ,method = RequestMethod.GET)
    public String add(@RequestParam Integer a, @RequestParam Integer b) {
        counterService.increment("hgc.count444");
        return packService.add(a,b)+"from:"+from;
    }

}